home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / include / pool.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  2.9 KB  |  132 lines

  1. #ifndef __POOL_H__
  2. #define __POOL_H__
  3. /*
  4.  *   $RCSfile: pool.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:08 $      
  7.  */ 
  8.  
  9. /**********************************************************************
  10. * EXODUS Database Toolkit Software
  11. * Copyright (c) 1991 Computer Sciences Department, University of
  12. *                    Wisconsin -- Madison
  13. * All Rights Reserved.
  14. *
  15. * Permission to use, copy, modify and distribute this software and its
  16. * documentation is hereby granted, provided that both the copyright
  17. * notice and this permission notice appear in all copies of the
  18. * software, derivative works or modified versions, and any portions
  19. * thereof, and that both notices appear in supporting documentation.
  20. *
  21. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  22. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  23. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  24. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  25. *
  26. * The EXODUS Project Group requests users of this software to return 
  27. * any improvements or extensions that they make to:
  28. *
  29. *   EXODUS Project Group 
  30. *     c/o David J. DeWitt and Michael J. Carey
  31. *   Computer Sciences Department
  32. *   University of Wisconsin -- Madison
  33. *   Madison, WI 53706
  34. *
  35. *     or exodus@cs.wisc.edu
  36. *
  37. * In addition, the EXODUS Project Group requests that users grant the 
  38. * Computer Sciences Department rights to redistribute these changes.
  39. **********************************************************************/
  40.  
  41. /*
  42.  *    define the forward declaration
  43.  */
  44. typedef struct _Pool    POOL;
  45.  
  46.  
  47. /*
  48.  *    define a type of function that takes a link and a message parameter
  49.  */
  50. #ifdef __cplusplus
  51.  
  52.     typedef char *(*ALLOCFUNC)(POOL *);
  53.  
  54. #elif defined(c_plusplus)
  55.  
  56.     typedef char *(*ALLOCFUNC)(POOL *);
  57.  
  58. #elif !defined(__cplusplus)
  59.  
  60.     typedef char *(*ALLOCFUNC)();
  61.  
  62. #else
  63.     source code error
  64. #endif
  65.  
  66.  
  67. /*
  68.  *    This defines the general structure of linked lists
  69.  *    that will be used throughout the storage manager
  70.  */
  71.  
  72. typedef struct _Pool {
  73.  
  74.     LIST        freeList;
  75.     ALLOCFUNC    allocMore;
  76.     FOUR        elements;
  77.     FOUR        currentUsed;
  78.     FOUR        maxUsed;
  79.     MAGIC        magic;
  80.  
  81. };
  82.  
  83.  
  84. /*
  85.  *    Define the magic number for pools
  86.  */
  87. #define POOLMAGIC        0x34516780
  88.  
  89.  
  90. /*
  91.  *    define the magic number check routine */
  92. #if LIST_CHECKING IS_ENABLED
  93.  
  94.  
  95. #define CHECK_POOL_MAGIC(_element)                            \
  96.                                                             \
  97.     if (_element->magic != POOLMAGIC)    {                    \
  98.                                                             \
  99.         SM_ERROR(TYPE_FATAL, esmINTERNAL);                    \
  100.     }
  101.  
  102. #define INIT_POOL_MAGIC(_element)                            \
  103.                                                             \
  104.     (_element)->magic = POOLMAGIC;
  105.  
  106.  
  107. #else
  108.  
  109. #define CHECK_POOL_MAGIC(_element)
  110.  
  111. #define INIT_POOL_MAGIC(_element)
  112.  
  113. #endif
  114.  
  115.  
  116. /*
  117.  *    define the function prototypes
  118.  */
  119. #ifdef __cplusplus
  120. extern "C" {
  121. #endif
  122.  
  123. extern void        initializePool(POOL *, ALLOCFUNC, FOUR);
  124. extern void        *poolDeq(POOL *);
  125. extern void        poolEnq(POOL *, LISTELEMENT *);
  126. extern void        poolMove(POOL *, LISTELEMENT *);
  127.  
  128. #ifdef __cplusplus
  129. }
  130. #endif
  131. #endif __POOL_H__
  132.